package cate.game.play.proce.action.ctx;

import cate.common.table.d.GDPlay;
import cate.game.play.config.AllPlayCfg;
import cate.game.play.part.TeamVS;
import cate.game.play.proce.action.po.ActionPO;
import cate.game.play.proce.play.PlayCtx;
import cate.game.play.proce.result.ActionResult;
import cate.game.play.proce.round.RoundCtx;
import cate.game.play.proce.stat.ActionStat;
import com.fasterxml.jackson.annotation.JsonIgnore;
import com.fasterxml.jackson.annotation.JsonProperty;
import easy.java.dev.note.NoteClass;
import easy.java.dev.note.NoteField;
import lombok.Data;

@NoteClass("基础行动ctx")
@Data
public abstract class ActionCtx<T extends ActionPO> {

	@NoteField("轮次ctx")
	protected RoundCtx round;

	@NoteField("需要记录的行动数据")
	protected T po;

	@NoteField("action统计")
	protected ActionStat stat;


	/**
	 * 追加结果
	 */
	public void addResult(ActionResult result) {
		this.po.addResult(result);
	}


	@JsonIgnore
	public RoundCtx getRound() {
		return round;
	}

	@JsonIgnore
	public PlayCtx getPlay() {
		return round.getPlay();
	}

	@JsonIgnore
	public AllPlayCfg getCfg() {
		return getPlay().getCfg();
	}

	@JsonIgnore
	public TeamVS getTeamVs() {
		return getPlay().teamVS;
	}

	//当前技能是否是主动技能
	@JsonProperty
	public boolean isActiveSkill() {
		if (po == null) {
			return false;
		}
		return po.type == GDPlay.ActionType.SKILL_ACTIVE;
	}
}
